package com.ruoyi.web.controller.mall.mallShopUser.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.web.controller.mall.mallShopUser.domain.MallShopUser;
import com.ruoyi.web.controller.mall.mallShopUser.service.IMallShopUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 商家入驻信息Controller
 * 
 * @author ruoyi
 * @date 2021-01-18
 */
@Controller
@RequestMapping("/mall/mallShopUser")
public class MallShopUserController extends BaseController
{
    private String prefix = "mall/mallShopUser";

    @Autowired
    private IMallShopUserService mallShopUserService;

//    @RequiresPermissions("mall:mallShopUser:view")
    @GetMapping()
    public String mallShopUser()
    {
        return prefix + "/mallShopUser";
    }

    /**
     * 查询商家入驻信息列表
     */
//    @RequiresPermissions("mall:mallShopUser:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(MallShopUser mallShopUser)
    {
        startPage();
        List<MallShopUser> list = mallShopUserService.selectMallShopUserList(mallShopUser);
        return getDataTable(list);
    }

    /**
     * 导出商家入驻信息列表
     */
//    @RequiresPermissions("mall:mallShopUser:export")
    @Log(title = "商家入驻信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(MallShopUser mallShopUser)
    {
        List<MallShopUser> list = mallShopUserService.selectMallShopUserList(mallShopUser);
        ExcelUtil<MallShopUser> util = new ExcelUtil<MallShopUser>(MallShopUser.class);
        return util.exportExcel(list, "mallShopUser");
    }

    /**
     * 新增商家入驻信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存商家入驻信息
     */
//    @RequiresPermissions("mall:mallShopUser:add")
    @Log(title = "商家入驻信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(MallShopUser mallShopUser)
    {
        return toAjax(mallShopUserService.insertMallShopUser(mallShopUser));
    }

    /**
     * 修改商家入驻信息
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        MallShopUser mallShopUser = mallShopUserService.selectMallShopUserById(id);
        mmap.put("mallShopUser", mallShopUser);
        return prefix + "/edit";
    }

    /**
     * 修改保存商家入驻信息
     */
//    @RequiresPermissions("mall:mallShopUser:edit")
    @Log(title = "商家入驻信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(MallShopUser mallShopUser)
    {
        return toAjax(mallShopUserService.updateMallShopUser(mallShopUser));
    }

    /**
     * 删除商家入驻信息
     */
//    @RequiresPermissions("mall:mallShopUser:remove")
    @Log(title = "商家入驻信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String[] ids)
    {
        return toAjax(mallShopUserService.deleteMallShopUserByIds(ids));
    }
}
